/*
 Copyright (C) 2010 Kristian Duske

 This file is part of TrenchBroom.

 TrenchBroom is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 TrenchBroom is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with TrenchBroom. If not, see <http://www.gnu.org/licenses/>.
 */

#pragma once

#include "Macros.h"

#include "vm/vec.h"

#include <memory>
#include <string>
#include <vector>

namespace tb::render
{
class AttrString;
class FontGlyph;
class FontTexture;

class TextureFont
{
private:
  std::unique_ptr<FontTexture> m_texture;
  std::vector<FontGlyph> m_glyphs;
  int m_ascend;
  int m_descend;
  int m_lineHeight;

  unsigned char m_firstChar;
  unsigned char m_charCount;

public:
  TextureFont(
    std::unique_ptr<FontTexture> texture,
    const std::vector<FontGlyph>& glyphs,
    int ascend,
    int descend,
    int lineHeight,
    unsigned char firstChar,
    unsigned char charCount);
  ~TextureFont();

  deleteCopyAndMove(TextureFont);

  int ascend() const;
  int descend() const;
  int lineHeight() const;

  std::vector<vm::vec2f> quads(
    const AttrString& string,
    bool clockwise,
    const vm::vec2f& offset = vm::vec2f{0, 0}) const;
  vm::vec2f measure(const AttrString& string) const;

  std::vector<vm::vec2f> quads(
    const std::string& string,
    bool clockwise,
    const vm::vec2f& offset = vm::vec2f{0, 0}) const;
  vm::vec2f measure(const std::string& string) const;

  void activate();
  void deactivate();
};

} // namespace tb::render
